package com.awesome.designpatterndemo.proxy.proxy3;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Author: zhangjingfang
 * Email:zhangjingfang@jeejio.com
 * Date: 2021/7/30 9:54 下午
 * Description:类描述
 */
public class DynamicProxy implements InvocationHandler {
    // 被代理的引用
    private Object obj;

    public DynamicProxy(Object obj) {
        this.obj = obj;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        // 调用被代理类对象的方法
        Object result = method.invoke(obj, args);
        return result;
    }
}